<template>
  <div class="header-container">
    <img src="../assets/font/学校.png" alt="" height="60px" width="60px">
    <span class="title">欢迎来到成电教务网</span>
    <el-divider direction="vertical"></el-divider>
    <i class="el-icon-user" style="margin-right: 18px"></i>
    <span class="name">{{ this.name }}</span>
    <el-button type="info" icon="el-icon-switch-button" @click="out" style="position: absolute;right:20px"></el-button>
  </div>
</template>

<script>
export default {
  name: "r-header",
  data(){
    return{
      name:'',
      studentid:'',
      teacherid:'',
    }
  },
  mounted() {
  // 在mounted钩子中获取数据
  this.name = localStorage.getItem('name');
  this.studentid = localStorage.getItem('studentId'||'');
  this.teacherid = localStorage.getItem('teacherId'||'');
},
  methods: {
    out() {
      localStorage.clear();  
      this.$router.push("/");
    },
  },
};
</script>

<style scoped>
.header-container {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  background: linear-gradient(to right, #4a34db, #b702ff);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.title {
  color: #fff;
  font-size: 18px;
  margin-right: 10px;
}

.name {
  color: #fff;
  font-size: 16px;
  margin-right: 10px;
}
</style>
